///*
// * Copyright 2020 The Android Open Source Project
// *
// * Licensed under the Apache License, Version 2.0 (the "License");
// * you may not use this file except in compliance with the License.
// * You may obtain a copy of the License at
// *
// *     https://www.apache.org/licenses/LICENSE-2.0
// *
// * Unless required by applicable law or agreed to in writing, software
// * distributed under the License is distributed on an "AS IS" BASIS,
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// * See the License for the specific language governing permissions and
// * limitations under the License.
// */
//
//package com.planta.ui.components
//
//import android.content.res.Configuration
//import androidx.compose.animation.animateColorAsState
//import androidx.compose.foundation.background
//import androidx.compose.foundation.interaction.MutableInteractionSource
//import androidx.compose.foundation.interaction.collectIsPressedAsState
//import androidx.compose.foundation.layout.Arrangement
//import androidx.compose.foundation.layout.Box
//import androidx.compose.foundation.layout.PaddingValues
//import androidx.compose.foundation.layout.height
//import androidx.compose.foundation.layout.heightIn
//import androidx.compose.foundation.layout.padding
//import androidx.compose.foundation.lazy.LazyRow
//import androidx.compose.foundation.lazy.items
//import androidx.compose.foundation.selection.toggleable
//import androidx.compose.foundation.shape.CircleShape
//import androidx.compose.material.Icon
//import androidx.compose.material.IconButton
//import androidx.compose.material.MaterialTheme
//import androidx.compose.material.Text
//import androidx.compose.material.icons.Icons
//import androidx.compose.material.icons.rounded.FilterList
//import androidx.compose.runtime.Composable
//import androidx.compose.runtime.getValue
//import androidx.compose.runtime.remember
//import androidx.compose.ui.Alignment
//import androidx.compose.ui.Modifier
//import androidx.compose.ui.graphics.Color
//import androidx.compose.ui.graphics.Shape
//import androidx.compose.ui.res.stringResource
//import androidx.compose.ui.tooling.preview.Preview
//import androidx.compose.ui.unit.dp
//import com.odqsb.fkjyg.R
//import com.planta.ui.theme.MainTheme
//
////@Composable
////fun FilterBar(filters: List<com.planta.model.Filter>) {
////    LazyRow(
////        verticalAlignment = Alignment.CenterVertically,
////        horizontalArrangement = Arrangement.spacedBy(8.dp),
////        contentPadding = PaddingValues(start = 12.dp, end = 8.dp),
////        modifier = Modifier.heightIn(min = 56.dp)
////    ) {
////        item {
////            IconButton(onClick = { /* todo */ }) {
////                Icon(
////                    imageVector = Icons.Rounded.FilterList,
////                    tint = MainTheme.colors.brand,
////                    contentDescription = null,
////                    modifier = Modifier.diagonalGradientBorder(
////                        colors = MainTheme.colors.interactiveSecondary,
////                        shape = CircleShape
////                    )
////                )
////            }
////        }
////        items(filters) { filter ->
////            FilterChip(filter)
////        }
////    }
////}
//
//@Composable
//fun FilterChip(
//    filter: com.planta.model.Filter,
//    modifier: Modifier = Modifier,
//    shape: Shape = MaterialTheme.shapes.small
//) {
//    val (selected, setSelected) = filter.enabled
//    val backgroundColor by animateColorAsState(
//        if (selected) MainTheme.colors.brandSecondary else MainTheme.colors.uiBackground
//    )
//    val border = Modifier.fadeInDiagonalGradientBorder(
//        showBorder = !selected,
//        colors = MainTheme.colors.interactiveSecondary,
//        shape = shape
//    )
//    val textColor by animateColorAsState(
//        if (selected) Color.Black else MainTheme.colors.textSecondary
//    )
//
//    MainSurface(
//        modifier = modifier.height(28.dp),
//        color = backgroundColor,
//        contentColor = textColor,
//        shape = shape,
//        elevation = 2.dp
//    ) {
//        val interactionSource = remember { MutableInteractionSource() }
//
//        val pressed by interactionSource.collectIsPressedAsState()
//        val backgroundPressed =
//            if (pressed) {
//                Modifier.offsetGradientBackground(
//                    MainTheme.colors.interactiveSecondary,
//                    200f,
//                    0f
//                )
//            } else {
//                Modifier.background(Color.Transparent)
//            }
//        Box(
//            modifier = Modifier
//                .toggleable(
//                    value = selected,
//                    onValueChange = setSelected,
//                    interactionSource = interactionSource,
//                    indication = null
//                )
//                .then(backgroundPressed)
//                .then(border),
//        ) {
//            Text(
//                text = filter.name,
//                style = MaterialTheme.typography.caption,
//                maxLines = 1,
//                modifier = Modifier.padding(
//                    horizontal = 20.dp,
//                    vertical = 6.dp
//                )
//            )
//        }
//    }
//}
//
//@Preview("default")
//@Preview("dark theme", uiMode = Configuration.UI_MODE_NIGHT_YES)
//@Preview("large font", fontScale = 2f)
//@Composable
//private fun FilterDisabledPreview() {
//    MainTheme {
//        FilterChip(com.planta.model.Filter(name = "Demo", enabled = false), Modifier.padding(4.dp))
//    }
//}
//
//@Preview("default")
//@Preview("dark theme", uiMode = Configuration.UI_MODE_NIGHT_YES)
//@Preview("large font", fontScale = 2f)
//@Composable
//private fun FilterEnabledPreview() {
//    MainTheme {
//        FilterChip(com.planta.model.Filter(name = "Demo", enabled = true))
//    }
//}
